﻿Public Class ChiTietPhieuNhapDAO
    Public Shared Sub insert(ByVal ctpn As ChiTietPhieuNhapDTO)
        Dim strSQL As String
        strSQL = "Insert into CHITIETHOADONNHAP(MAMATHANG, MAHOADONNHAP,SOLUONGNHAP, MACHITIETHOADONNHAP,DONGIANHAP) values('" & ctpn.MaMatHang & "','" & ctpn.MaHoaDonNhap & "'," & ctpn.SoLuongNhap & "," & ctpn.MaChiTietHoaDonNhap & "," & ctpn.DonGiaNhap & ")"

        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Function selectALL(ByVal MaHoaDonNhap As String) As DataTable
        Dim strSQL As String
        strSQL = "select * from CHITIETHOADONNHAP WHERE MAHOADONNHAP = " & MaHoaDonNhap

        Dim dt As DataTable
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
    Public Shared Sub delete(ByVal MaHoaDonNhap As String)
        Dim strSQL As String
        strSQL = "delete from CHITIETHOADONNHAP where MACHITIETHOADONNHAP = '" & MaHoaDonNhap & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Function MaTuTang() As Integer
        Dim strSQl As String
        Dim a As DataTable
        Dim b As Integer
        strSQl = "select count(MACHITIETHOADONNHAP) from CHITIETHOADONNHAP"
        a = SQLProvider.ExecQuery(strSQl)
        b = a.Rows(0).Item(0).ToString()
        Return b + 1
    End Function
End Class
